package classroom;

public class Student extends People {

    public Student(int age, String name, String words, String expression) {
        super(age, name, words, expression);
    }

    @Override
    protected String words() {
        return  words;
    }

    @Override
    protected String action() {
        return name + "同学" +
                action + "。";
    }

    @Override
    public void answerQuestion(String answer) {
        System.out.println("A--Student " + name + " :");
        if(answer==null){
            System.out.println("我也不知道");
            return;
        }
        double random = Math.random();
        //假设学生有50%的概率知道答案。
        if (random >= 0.5) {
            System.out.println("答案我知道，是：" + answer);
        } else {
            System.out.println("答案是...我也不知道");
        }
    }

    @Override
    public void askQuestion(Answerable answerable, String question) {
        System.out.println("Q--Student " + name + " :");
        System.out.println("我想问个问题：" + question);
        //通知那个人（answerable）该回答问题了。
        answerable.answerQuestion(Classroom.getAnswer(question));
    }
}
